package fhp.hlhj.giantfold.activity.malls
import android.support.v7.widget.GridLayoutManager
import android.view.LayoutInflater
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import fhp.hlhj.giantfold.BaseActivity
import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.adapter.TabBaoHeaderGridViewAdp
import kotlinx.android.synthetic.main.activity_jing_dong_aty.*
import kotlinx.android.synthetic.main.jingdong_header.view.*

class JingDongAty : BaseActivity() {
    private var datas = ArrayList<String>()
    private lateinit var headView:View
    private lateinit var adapter: BaseQuickAdapter<String, BaseViewHolder>
    private lateinit var gridViewAdp:TabBaoHeaderGridViewAdp
    override fun getContentId(): Int = R.layout.activity_jing_dong_aty
    override fun initView() {
        val manager=GridLayoutManager(this,2)
        recyclerview.layoutManager=manager
        adapter=object :BaseQuickAdapter<String,BaseViewHolder>(R.layout.tabbao_item,datas){
            override fun convert(helper: BaseViewHolder?, item: String?) {
                helper?.setText(R.id.itemPrice,"10.00")
            }
        }
        recyclerview.adapter=adapter

        headView=LayoutInflater.from(this).inflate(R.layout.jingdong_header,null)

        gridViewAdp = TabBaoHeaderGridViewAdp(this, datas)
        headView.gridView.adapter=gridViewAdp

        adapter.addHeaderView(headView)
    }

    override fun initData() {
        for (i in 1..8){
            datas.add(i.toString())
        }
        adapter.notifyDataSetChanged()
        gridViewAdp.notifyDataSetChanged()
    }
    override fun initListener() {
        headView.btExit.setOnClickListener {
            finish()
        }

    }
}
